package socdev.data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;

public class User implements Serializable{

	public String nick;
	public String fullname;
	public String description;
	public String role;
	
	public User(String nick, String fullname, String description, String role) {
		this.nick = nick;
		this.fullname = fullname;
		this.description = description;
		this.role = role;
	}
	
	public static User createFromJson(JSONObject json) throws JSONException {
		if (json.isNull("role"))return new User(json.getString("nick"), json.getString("fullname"), json.getString("description"), null);
		return new User(json.getString("nick"), json.getString("fullname"), json.getString("description"), json.getString("role"));
	}
	
	public String getId() {
		return nick;
	}
	
	public List<NameValuePair> getNameValuePairs(List<NameValuePair> nameValuePairs) {
 
	
		nameValuePairs.add(new BasicNameValuePair("login",nick));
     	return nameValuePairs;
		
	}
}
